package com.excel.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.excel.pojo.Emp;

import java.util.ArrayList;
import java.util.List;

public class EmpParseListener extends AnalysisEventListener<Emp> {

    private List<Emp> empList = new ArrayList<Emp>();

    //该方法每解析一行数据, 就会触发一次
    public void invoke(Emp data, AnalysisContext context) {
        System.out.println("-----> 解析到一行数据");
        empList.add(data);
    }
	
    //该方法是等所有行解析完毕之后触发
    public void doAfterAllAnalysed(AnalysisContext context) {
        System.out.println("全部数据解析完毕");
        for (Emp emp : empList) {
            System.out.println(emp);
        }
    }
}